<?php
namespace app\common\validate;

use think\Validate;

class Admin extends Validate
{
    protected $rule = [
        'account'    => 'require|min:3|unique:admin',
        'password'   => 'require|min:6',
        'rePassword' => 'require|confirm:password',
        'username'   => 'require|min:1|unique:admin',
        'phone'      => '/^1[345789]\d{9}$/|unique:admin',
        'role_id'   => 'require|min:1',
    ];

    protected $message = [
        'account.require'  => '账号不能为空',
        'account.min'      => '账号最短3位',
        'account.unique'   => '账号已存在,请重新输入',
        'password'         => '密码不能为空',
        'password.min'     => '密码长度不能少于6位',
        'rePassword'       => '确认密码不正确',
        'username.require' => '姓名不能为空',
        'username.min'     => '姓名长度不能少于1位',
        'username.unique'  => '姓名已存在,请重新输入',
        'phone'            => '请填写正确的手机号码格式',
        'phone.unique'     => '手机号码已经被使用，请重新填写',
        'status'           => '状态必须为数字整数（0,1）',
        'role_id'          => '请选择角色',
    ];

    protected $scene = [
        'add'      => ['account','username', 'password', 'rePassword', 'phone','pid','rank','uid','role_id'],
        'edit'     => ['username', 'phone','account','role_id'],
        'password' => ['password', 'rePassword'],
        'status'   => ['status'],
    ];




}